import wx
import picbtn


class PopBtn(picbtn.PicBtn):
    def  __init__(self,parent,id,picpath1,picpath2,tip,size=None):
        picbtn.PicBtn.__init__(self,parent,id,picpath1,picpath2,size,tip)
        self.Bind(wx.EVT_BUTTON, self.OnManu, self)
        self.btnmenu = wx.Menu()
    
    def AddManu(self,text,func):
        num = wx.NewId()
        self.btnmenu.Append( num, text)
        self.Bind(wx.EVT_MENU, func, id = num)
            
    def OnManu(self, event):
        self.PopupMenu(self.btnmenu)

def testmenu(event):
    dlg = wx.MessageDialog(None, 'Hello from Python and wxPython!',
                           'A Message Box',
                           wx.OK | wx.ICON_INFORMATION)
    dlg.ShowModal()
    dlg.Destroy()
    
    
if __name__ == "__main__":

    app = wx.PySimpleApp()
    frame = wx.Frame(None,-1)
    panel = wx.Panel(frame,-1)

    #btn = picbtn.PicBtn(panel,-1,"D:/test/x2.bmp","D:/test/x1.bmp",(30,15),"test tip")
    #btn = wx.Button(panel,-1)
    popbtn = PopBtn(panel,-1,"D:/test/x2.bmp","D:/test/x1.bmp",(30,15),"test tip")
    popbtn.AddManu("ff",testmenu)
    popbtn.AddManu("ff2",testmenu)
    frame.Show()
    app.MainLoop()

        
        